package mylab.commons.pool;

import mylab.object.Employee;

import org.apache.commons.pool.BasePoolableObjectFactory;

public class EmployeeFactory extends BasePoolableObjectFactory {

  public Object makeObject() {
    return new Student();
  }

  public boolean validateObject(Object obj) {
    if(obj instanceof Student) {
      if(((Student)obj).getName() == null)
        return true;
    }
    return false;
  }

  public void passivateObject(Object obj) throws Exception {
    if(obj instanceof Student) {
      ((Student)obj).setName(null);
    } else throw new Exception("Unknown object");
  }
}